package com.bit.forumdemo.pojo.public_pojo;


import com.bit.forumdemo.util.final_data.ResponseCode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 通用响应实体类
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ResponsePojo implements Serializable {

    //响应码
    private String code;

    //响应数据
    private Object data;

    //请求成功响应数据
    public static ResponsePojo seccess(Object data){
        return ResponsePojo.builder().code(ResponseCode.SUCCESS).data(data).build();
    }

    //请求成功不携带数据
    public static ResponsePojo seccess(){
        return ResponsePojo.builder().code(ResponseCode.SUCCESS).build();
    }

    //请求失败响应
    public static ResponsePojo fail(){
        return ResponsePojo.builder().code(ResponseCode.FAIL).build();
    }
}
